<template>
  <div class="box">
    <el-row>
      <el-col :span="24">
        <el-tabs v-model="activeName" @tab-click="handleClick">
          <el-tab-pane label="客户价格" name="first">
            <el-row>
              <el-col :span="24">
                <div class="header">
                  <el-form
                    ref="khForm"
                    :model="khForm"
                    label-width="100px"
                    class="flex"
                  >
                    <el-form-item label="所属网点" style="margin-left: 10px">
                      <el-select
                        v-model="khForm.networkNameId"
                        placeholder="请选择网点"
                        style="width: 286px"
                      >
                        <el-option
                          v-for="item in networkList"
                          :key="item.id"
                          :label="item.networkName"
                          :value="item.id"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="客户名称">
                      <el-input
                        v-model="khForm.clientName"
                        placeholder="请输入客户名称"
                        style="width: 286px"
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="客户编号">
                      <el-input
                        v-model="khForm.clientCode"
                        placeholder="请输入报价编号"
                        style="width: 286px"
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="客户昵称">
                      <el-input
                        v-model="khForm.nickName"
                        placeholder="请输入客户昵称"
                        style="width: 286px"
                      ></el-input>
                    </el-form-item>
                    <el-form-item style="margin-left: 15px">
                      <el-button type="primary" @click="getKhList"
                        >查询</el-button
                      >
                      <el-button @click="khClear">重置</el-button>
                    </el-form-item>
                    <el-form-item
                      label="有效客户筛选"
                      style="margin-left: 10px"
                    >
                      <el-select
                        v-model="khForm.clientScreen"
                        placeholder="请选择有效客户筛"
                        style="width: 286px"
                      >
                        <el-option
                          label="近一个月内发货"
                          value="近一个月内发货"
                        ></el-option>
                        <el-option
                          label="近两个月内发货"
                          value="近两个月内发货"
                        ></el-option>
                        <el-option
                          label="近三个月内发货"
                          value="近三个月内发货"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="父客户">
                      <el-input
                        v-model="khForm.parentClientId"
                        placeholder="请输入父客户"
                        style="width: 286px"
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="客户类型">
                      <el-select
                        v-model="khForm.clientType"
                        placeholder="请选择客户类型"
                        style="width: 286px"
                      >
                        <el-option
                          label="本网点客户"
                          value="本网点客户"
                        ></el-option>
                        <el-option
                          label="业务员客户"
                          value="业务员客户"
                        ></el-option>
                        <el-option
                          label="虚拟承包区客户"
                          value="虚拟承包区客户"
                        ></el-option>
                        <el-option
                          label="承包区客户"
                          value="承包区客户"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="所属对象">
                      <el-input
                        v-model="khForm.objectName"
                        placeholder="请输入所属对象"
                        style="width: 286px"
                      ></el-input>
                    </el-form-item>

                    <el-form-item label="平台来源" style="margin-left: 10px">
                      <el-select
                        v-model="khForm.clientSourceId"
                        placeholder="请选择平台来源"
                        style="width: 286px"
                      >
                        <el-option
                          v-for="item in PlatformAllList"
                          :key="item.id"
                          :label="item.platformSource"
                          :value="item.id"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="客户状态">
                      <el-select
                        v-model="khForm.clientStatus"
                        placeholder="请选择客户状态"
                        style="width: 286px"
                      >
                        <el-option label="有效" value="有效"></el-option>
                        <el-option label="无效" value="无效"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-form>
                </div>
              </el-col>
            </el-row>
            <el-row type="flex" justify="space-between">
              <el-col :span="6">
                <div>当前页共{{ khTotal }}项</div>
              </el-col>
            </el-row>
            <el-row type="flex" justify="space-between">
              <el-col :span="24">
                <el-table
                  :data="khTable"
                  :cell-style="{ textAlign: 'center' }"
                  :header-cell-style="{ textAlign: 'center' }"
                  border
                  style="width: 100%"
                >
                  <el-table-column
                    fixed
                    prop="clientName"
                    label="客户名称"
                    width="150"
                  >
                  </el-table-column>
                  <el-table-column
                    fixed
                    prop="nickName"
                    label="客户昵称"
                    width="120"
                  >
                  </el-table-column>
                  <el-table-column
                    prop="clientCode"
                    label="客户编号"
                    width="120"
                  >
                  </el-table-column>
                  <el-table-column
                    prop="clientSource.clientSource"
                    label="平台来源"
                    width="120"
                  >
                  </el-table-column>
                  <el-table-column
                    prop="parentClientId"
                    label="父客户"
                    width="300"
                  >
                  </el-table-column>
                  <el-table-column
                    prop="clientType"
                    label="客户类型"
                    width="120"
                  >
                  </el-table-column>
                  <el-table-column
                    prop="objectName"
                    label="所届对象名称"
                    width="120"
                  >
                  </el-table-column>
                  <el-table-column
                    prop="selletType"
                    label="结算方式"
                    width="120"
                  >
                  </el-table-column>
                  <el-table-column
                    prop="sheetFee"
                    label="面单费(元)"
                    width="120"
                  >
                  </el-table-column>
                  <el-table-column
                    prop="preSheetFee"
                    label="预收面单费(元)"
                    width="120"
                  >
                  </el-table-column>
                  <el-table-column
                    prop="unSheetFee"
                    label="未收面单费(元)"
                    width="120"
                  >
                  </el-table-column>
                  <el-table-column
                    prop="objectSellPrice"
                    label="物料销售价(元)"
                    width="120"
                  >
                  </el-table-column>
                  <el-table-column
                    prop="incomingPrice"
                    label="来单单价(元)"
                    width="120"
                  >
                  </el-table-column>
                  <el-table-column
                    prop="fullLimit"
                    label="日充值上限"
                    width="120"
                  >
                  </el-table-column>
                  <el-table-column
                    prop="clientStatus"
                    label="客户状态"
                    width="120"
                  >
                  </el-table-column>

                  <el-table-column label="操作" width="120" fixed="right">
                    <template slot-scope="scope">
                      <el-button
                        @click="edit(scope.row)"
                        type="text"
                        size="small"
                        >修改</el-button
                      >
                    </template>
                  </el-table-column>
                </el-table>
              </el-col>
            </el-row>
            <div class="block" style="display: flex; justify-content: end">
              <el-pagination
                @size-change="khHandleSizeChange"
                @current-change="khHandleCurrentChange"
                :current-page="currentPage4"
                :page-sizes="[10, 20, 30, 40]"
                :page-size="10"
                layout="total, sizes, prev, pager, next, jumper"
                :total="khTotal"
              >
              </el-pagination>
            </div>
          </el-tab-pane>
          <el-tab-pane label="业务员价格" name="second">
            <el-row>
              <el-col :span="24">
                <div class="header">
                  <el-form
                    ref="ywyForm"
                    :model="ywyForm"
                    label-width="100px"
                    class="flex"
                  >
                    <el-form-item label="网点名称">
                      <el-select
                        v-model="ywyForm.networkNameId"
                        placeholder="请选择活动区域"
                        style="width: 286px"
                      >
                        <el-option
                          v-for="item in networkList"
                          :key="item.id"
                          :label="item.networkName"
                          :value="item.id"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                    
                    <el-form-item label="业务员名称">
                      <el-input
                        v-model="ywyForm.salesmanName"
                        placeholder="请输入业务员名称"
                        style="width: 286px"
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="业务员编号">
                      <el-input
                        v-model="ywyForm.salesmanCode"
                        placeholder="请输入业务员编号"
                        style="width: 286px"
                      ></el-input>
                    </el-form-item>
                     <el-form-item label="业务员状态">
                      <el-select
                        v-model="ywyForm.salesmanStatus"
                        placeholder="请选择业务员状态"
                        style="width: 286px"
                      >
                        <el-option label="有效" value="有效"></el-option>
                        <el-option label="无效" value="无效"></el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item style="margin-left: 15px">
                      <el-button type="primary" @click="getYwyList"
                        >查询</el-button
                      >
                      <el-button @click="ywyClear">重置</el-button>
                    </el-form-item>
                   
                    
                  </el-form>
                </div>
              </el-col>
            </el-row>
            <el-row type="flex" justify="space-between">
              <el-col :span="6">
                <div>当前页共{{ywyTotal}}项</div>
              </el-col>
              
            </el-row>
            <el-row type="flex" justify="space-between">
              <el-col :span="24">
                <el-table :data="ywyTable" :cell-style="{ textAlign: 'center' }"
                :header-cell-style="{ textAlign: 'center' }" border style="width: 100%">
                  <el-table-column
                    fixed
                    prop="salesmanName"
                    label="业务员名称"
                  >
                  </el-table-column>
                  <el-table-column fixed prop="salesmanCode" label="业务员编号" >
                  </el-table-column>
                  <el-table-column prop="previousName" label="上级名称" >
                  </el-table-column>
                  <el-table-column prop="sheetFee" label="面单费(元)" >
                  </el-table-column>
                  <el-table-column prop="objectSellPrice" label="物料销售价(元)" >
                  </el-table-column>
                  <el-table-column prop="salesmanStatus" label="业务员状态" >
                  </el-table-column>
                  
                  <el-table-column  label="操作" >
                    <template slot-scope="scope">
                      <el-button
                        @click="editYwy(scope.row)"
                        type="text"
                        size="small"
                        >修改</el-button
                      >
                    </template>
                  </el-table-column>
                </el-table>
              </el-col>
            </el-row>
            <div class="block" style="display: flex; justify-content: end">
              <el-pagination
                @size-change="ywyHandleSizeChange"
                @current-change="ywyHandleCurrentChange"
                :current-page="currentPage4"
                :page-sizes="[10, 20, 30, 40]"
                :page-size="10"
                layout="total, sizes, prev, pager, next, jumper"
                :total="ywyTotal"
              >
              </el-pagination>
            </div>
          </el-tab-pane>
          <el-tab-pane label="承包区价格" name="third"
            ><el-row>
              <el-col :span="24">
                <div class="header">
                  <el-form
                    ref="cbqForm"
                    :model="cbqForm"
                    label-width="100px"
                    class="flex"
                  >
                    <el-form-item label="网点名称">
                      <el-select
                        v-model="cbqForm.networkNameId"
                        placeholder="请选择活动区域"
                        style="width: 286px"
                      >
                        <el-option
                          v-for="item in networkList"
                          :key="item.id"
                          :label="item.networkName"
                          :value="item.id"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="承包区名称">
                      <el-input
                        v-model="cbqForm.contractName"
                        placeholder="请输入承包区名称"
                        style="width: 286px"
                      ></el-input>
                    </el-form-item>
                     <el-form-item label="承包区编号">
                      <el-input
                        v-model="cbqForm.contractCode"
                        placeholder="请输入承包区编号"
                        style="width: 286px"
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="承包区状态">
                      <el-select
                        v-model="cbqForm.contractStatus"
                        placeholder="请选择活动区域"
                        style="width: 286px"
                      >
                        <el-option label="有效" value="有效"></el-option>
                        <el-option label="无效" value="无效"></el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item style="margin-left: 15px">
                      <el-button type="primary" @click="getCbqList"
                        >查询</el-button
                      >
                      <el-button @click="cbqClear">重置</el-button>
                    </el-form-item>
                  </el-form>
                </div>
              </el-col>
            </el-row>
            <el-row type="flex" justify="space-between">
              <el-col :span="6">
                <div>当前页共{{cbqTotal}}项</div>
              </el-col>
             
            </el-row>
            <el-row type="flex" justify="space-between">
              <el-col :span="24">
                <el-table :data="cbqTable" :cell-style="{ textAlign: 'center' }"
                :header-cell-style="{ textAlign: 'center' }" border style="width: 100%">
                  <el-table-column
                    prop="contractName"
                    label="承包区名称"
                  >
                  </el-table-column>
                  <el-table-column fixed prop="contractCode" label="承包区编号" >
                  </el-table-column>
                  <el-table-column prop="contractType" label="承包区类型" >
                  </el-table-column>
                  <el-table-column prop="sheetFee" label="面单费(元)" >
                  </el-table-column>
                  <el-table-column prop="objectSellPrice" label="物料销售价(元)" >
                  </el-table-column>
                  <el-table-column prop="contractStatus" label="承包区状态" >
                  </el-table-column>
                  <el-table-column label="操作" >
                     <template slot-scope="scope">
                      <el-button
                        @click="editCbq(scope.row)"
                        type="text"
                        size="small"
                        >修改</el-button
                      >
                    </template>
                  </el-table-column>
                </el-table>
              </el-col>
            </el-row>
            <div class="block" style="display: flex; justify-content: end">
              <el-pagination
                @size-change="cbqHandleSizeChange"
                @current-change="cbqHandleCurrentChange"
                :current-page="currentPage4"
                :page-sizes="[10, 20, 30, 40]"
                :page-size="10"
                layout="total, sizes, prev, pager, next, jumper"
                :total="cbqTotal"
              >
              </el-pagination>
            </div>
          </el-tab-pane>
          <el-tab-pane label="兜底价格" name="fourth"
            ><el-row>
              <el-col :span="24">
                <div class="header">
                  <el-form
                    ref="ddForm"
                    :model="ddForm"
                    label-width="100px"
                    class="flex"
                  >
                   <el-form-item label="网点名称">
                      <el-select
                        v-model="ddForm.networkNameId"
                        placeholder="请选择活动区域"
                        style="width: 286px"
                      >
                        <el-option
                          v-for="item in networkList"
                          :key="item.id"
                          :label="item.networkName"
                          :value="item.id"
                        ></el-option>
                      </el-select>
                    </el-form-item>

                    <el-form-item label="面单编号">
                      <el-input
                        v-model="ddForm.sheetCode"
                        placeholder="请输入面单编号"
                        style="width: 286px"
                      ></el-input>
                    </el-form-item>

                    <el-form-item label="面单名称">
                      <el-input
                        v-model="ddForm.sheetName"
                        placeholder="请输入面单名称"
                        style="width: 286px"
                      ></el-input>
                    </el-form-item>
                   
                    <el-form-item style="margin-left: 15px">
                      <el-button type="primary" @click="getDdList"
                        >查询</el-button
                      >
                      <el-button @click="ddClear">重置</el-button>
                    </el-form-item>
                  </el-form>
                </div>
              </el-col>
            </el-row>
            <el-row type="flex" justify="space-between">
              <el-col :span="6">
                <div>当前页共{{ddTotal}}项</div>
              </el-col>
             
            </el-row>
            <el-row type="flex" justify="space-between">
              <el-col :span="24">
                <el-table :data="ddTable" :cell-style="{ textAlign: 'center' }"
                :header-cell-style="{ textAlign: 'center' }" border style="width: 100%">
                  <el-table-column
                    prop="sheetName"
                    label="面单名称"
                  >
                  </el-table-column>
                  <el-table-column fixed prop="sheetCode" label="面单编号" >
                  </el-table-column>
                  <el-table-column prop="minPay" label="最小购买数" >
                  </el-table-column>
                  <el-table-column prop="sheetFee" label="面单费(元)" >
                  </el-table-column>
                  <el-table-column prop="objectSellPrice" label="物料销售价(元)" >
                  </el-table-column>
                  <el-table-column  label="操作" >
                    <template slot-scope="scope">
                      <el-button
                        @click="editDd(scope.row)"
                        type="text"
                        size="small"
                        >修改</el-button
                      >
                    </template>
                  </el-table-column>
                </el-table>
              </el-col>
            </el-row>
            <div class="block" style="display: flex; justify-content: end">
              <el-pagination
                @size-change="ddHandleSizeChange"
                @current-change="ddHandleCurrentChange"
                :current-page="currentPage4"
                :page-sizes="[10, 20, 30, 40]"
                :page-size="10"
                layout="total, sizes, prev, pager, next, jumper"
                :total="ddTotal"
              >
              </el-pagination>
            </div>
          </el-tab-pane>
        </el-tabs>
      </el-col>
    </el-row>
    <el-dialog
      title="编辑"
      :visible.sync="dialogVisible"
      width="30%"
    >
      <el-form ref="editkhForm" v-if="activeName == 'first'" :model="editkhForm" label-width="80px">
        <el-form-item label="客户名称" >
          <el-input v-model="editkhForm.clientName" disabled></el-input>
        </el-form-item>
        <el-form-item label="客户昵称">
           <el-input v-model="editkhForm.nickName" disabled></el-input>
        </el-form-item>
        <el-form-item label="客户编号">
            <el-input v-model="editkhForm.clientCode" disabled></el-input>
        </el-form-item>
        <el-form-item label="平台来源">
            <el-input v-model="editkhForm.clientSource" disabled></el-input>
        </el-form-item>
        <el-form-item label="结算方式">
    <el-select v-model="editkhForm.selletType" placeholder="请选择活动区域">
      <el-option label="预付" value="预付"></el-option>
      <el-option label="月结" value="月结"></el-option>
    </el-select>
  </el-form-item>
        <el-form-item label="面单费(元)">
             <el-input v-model="editkhForm.sheetFee" type="number" placeholder="只能输入数字"></el-input>
        </el-form-item>
         <el-form-item label="日充值上限">
             <el-input v-model="editkhForm.fullLimit" type="number" placeholder="只能输入数字"></el-input>
        </el-form-item>
      </el-form>

      <!-- 业务员 -->
      <el-form ref="editYwyForm" v-if="activeName == 'second'" :model="editYwyForm" label-width="80px">
        <el-form-item label="业务员名称" >
          <el-input v-model="editYwyForm.salesmanName" disabled></el-input>
        </el-form-item>
        <el-form-item label="业务员编号">
            <el-input v-model="editYwyForm.salesmanCode" disabled></el-input>
        </el-form-item>
        <el-form-item label="面单费(元)">
             <el-input v-model="editYwyForm.sheetFee" type="number" placeholder="只能输入数字"></el-input>
        </el-form-item>
      </el-form>

      <!-- 承包区 -->
      <el-form ref="editCbqForm" v-if="activeName == 'third'" :model="editCbqForm" label-width="80px">
        <el-form-item label="承包区名称" >
          <el-input v-model="editCbqForm.contractName" disabled></el-input>
        </el-form-item>
        <el-form-item label="承包区编号">
            <el-input v-model="editCbqForm.contractCode" disabled></el-input>
        </el-form-item>
        <el-form-item label="面单费(元)">
             <el-input v-model="editCbqForm.sheetFee" type="number" placeholder="只能输入数字"></el-input>
        </el-form-item>
      </el-form>

      <!-- 兜底 -->
      <el-form ref="editDdForm" v-if="activeName == 'fourth'" :model="editDdForm" label-width="80px">
        <el-form-item label="承包区名称" >
          <el-input v-model="editDdForm.sheetName" disabled></el-input>
        </el-form-item>
        <el-form-item label="承包区编号">
            <el-input v-model="editDdForm.sheetCode" disabled></el-input>
        </el-form-item>
        <el-form-item label="面单费(元)">
             <el-input v-model="editDdForm.sheetFee" type="number" placeholder="只能输入数字"></el-input>
        </el-form-item>
      </el-form>


      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="editTrue"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { getOutletsList, getPlatformAll, clientSearch,updateKhSearch,salesmanTableSearch,updateSalesman,updateContract,contractTableSearch,updateUnderpay,underpayTableSearch } from "@/api/dashboard";
export default {
  data() {
    return {
      dialogVisible: false,
    
        currentPage4: 1,

      editkhForm:{
        fullLimit:'',
        sheetFee:'',
        selletType:'',
      },
      editYwyForm:{
        sheetFee:''
      },
      editCbqForm:{
        sheetFee:''
      },
      editDdForm:{
        sheetFee:''
      },
      khForm: {
        clientCode: "",
        clientName: "",
        clientScreen: "",
        clientSourceId: "",
        clientStatus: "",
        clientType: "",
        networkNameId: "",
        nickName: "",
        objectName: "",
        pageDate: {
          pageNum: 1,
          pageSize: 10,
        },
        parentClientId: "",
      },
      ywyForm:{
        networkNameId:'',
        salesmanName:'',
        salesmanCode:'',
        salesmanStatus:'',
        pageDate: {
          pageNum: 1,
          pageSize: 10,
        },
      },
      cbqForm:{
        networkNameId:'',
        contractName:'',
        contractCode:'',
        contractStatus:'',
        pageDate: {
          pageNum: 1,
          pageSize: 10,
        },
      },
      ddForm:{
        networkNameId:'',
        sheetName:'',
        sheetCode:'',
        pageDate: {
          pageNum: 1,
          pageSize: 10,
        },
      },
      
      // 客户表格
      khTable: [],
      // 业务员表格
      ywyTable:[],
       // 承包区表格
      cbqTable:[],
       // 兜底表格
      ddTable:[],
      khTotal: 0,
      ywyTotal: 0,
      ddTotal: 0,
      cbqTotal: 0,
      activeName: "first",
      // 网点列表
      networkList: [],

      // 平台来源
      PlatformAllList: [],
    };
  },
  created() {
    this.getOutLet();
    this.getPlatformList();
    this.getKhList();
  },
  methods: {
    // 获取平台来源
    getPlatformList() {
      getPlatformAll().then((res) => {
        if (res.code == 200) {
          this.PlatformAllList = res.data;
        }
      });
    },
    // 获取网点列表
    getOutLet() {
      getOutletsList().then((res) => {
        if (res.code == 200) {
          this.networkList = res.data;
        }
      });
    },
    getKhList() {
      for (const key in this.khForm) {
        // Check if the value is empty (assuming empty means falsy in this context)
        if (!this.khForm[key]) {
          // If the value is empty, delete the key from mxForm
          delete this.khForm[key];
        }
      }
      clientSearch(this.khForm).then((res) => {
        if (res.code == 200) {
          this.khTable = res.data.data;
          this.khTotal = res.data.total;
          this.khForm.pageDate.pageNum = res.data.pages;
        } else {
            this.khTable = []
        }
      });
    },

    // 搜索业务员
    getYwyList() {
      for (const key in this.ywyForm) {
        // Check if the value is empty (assuming empty means falsy in this context)
        if (!this.ywyForm[key]) {
          // If the value is empty, delete the key from mxForm
          delete this.ywyForm[key];
        }
      }
      salesmanTableSearch(this.ywyForm).then((res) => {
        if (res.code == 200) {
          this.ywyTable = res.data.data;
          this.ywyTotal = res.data.total;
          this.ywyForm.pageDate.pageNum = res.data.pages;
        } else {
            this.ywyTable = []
        }
      });
    },

    // 搜索承包区
    getCbqList() {
      for (const key in this.cbqForm) {
        // Check if the value is empty (assuming empty means falsy in this context)
        if (!this.cbqForm[key]) {
          // If the value is empty, delete the key from mxForm
          delete this.cbqForm[key];
        }
      }
      contractTableSearch(this.cbqForm).then((res) => {
        if (res.code == 200) {
          this.cbqTable = res.data.data;
          this.cbqTotal = res.data.total;
          this.cbqForm.pageDate.pageNum = res.data.pages;
        } else {
            this.cbqTable = []
        }
      });
    },

    // 搜索兜底
    getDdList() {
      for (const key in this.ddForm) {
        // Check if the value is empty (assuming empty means falsy in this context)
        if (!this.ddForm[key]) {
          // If the value is empty, delete the key from mxForm
          delete this.ddForm[key];
        }
      }
      underpayTableSearch(this.ddForm).then((res) => {
        if (res.code == 200) {
          this.ddTable = res.data.data;
          this.ddTotal = res.data.total;
          this.ddForm.pageDate.pageNum = res.data.pages;
        } else {
            this.ddTable = []
        }
      });
    },
    // 修改客户
    edit(data) {
        this.editkhForm.clientName = data.clientName
        this.editkhForm.nickName = data.nickName
        this.editkhForm.clientCode = data.clientCode
        this.editkhForm.clientSource = data.clientSource.clientSource
        this.editkhForm.fullLimit = data.fullLimit
        this.editkhForm.sheetFee = data.sheetFee
        this.editkhForm.selletType = data.selletType
        this.editkhForm.id =  data.id


      this.dialogVisible = true;
    },
    
    // 确认修改
    editTrue(){
        if (this.activeName == 'first') {
            this.edidKhTrue()
        } else if (this.activeName == 'second') {
            this.editYwyTrue()
        } else if (this.activeName == 'third') {
            this.editCbqTrue()
        } else if (this.activeName == 'fourth') {
            this.editDdTrue()
        }
    },

    // 客户确认修改
    edidKhTrue(){
        const ff = {
            fullLimit:this.editkhForm.fullLimit,
            sheetFee: this.editkhForm.sheetFee,
            selletType:this.editkhForm.selletType,
            id: this.editkhForm.id
        }
        updateKhSearch(ff).then((res) => {
        if (res.code == 200) {
            this.$message({
          message: '修改成功',
          type: 'success'
        });
           this.dialogVisible = false
           this.getKhList()
        }
      });

    },

     // 承包区修改
    editCbq(data){
        console.log(data)
        this.editCbqForm.contractName = data.contractName
        this.editCbqForm.contractCode = data.contractCode
        this.editCbqForm.sheetFee = data.sheetFee
        this.editCbqForm.id = data.id
        this.dialogVisible = true;
    },
     // 承包区确认修改
    editCbqTrue(){
        const ff = {
            contractName:this.editCbqForm.salesmanName,
            contractCode: this.editCbqForm.salesmanCode,
            sheetFee:this.editCbqForm.sheetFee,
            id: this.editCbqForm.id
        }
        updateContract(ff).then((res) => {
        if (res.code == 200) {
            this.$message({
          message: '修改成功',
          type: 'success'
        });
           this.dialogVisible = false
           this.getCbqList()
        }
      });
    },

    // 兜底修改
    editDd(data){
        console.log(data)
        this.editDdForm.sheetName = data.sheetName
        this.editDdForm.sheetCode = data.sheetCode
        this.editDdForm.sheetFee = data.sheetFee
        this.editDdForm.id = data.id
        this.dialogVisible = true;
    },

    // 兜底确认修改
    editDdTrue(){
        const ff = {
            sheetName:this.editDdForm.salesmanName,
            sheetCode: this.editDdForm.salesmanCode,
            sheetFee:this.editDdForm.sheetFee,
            id: this.editDdForm.id
        }
        updateUnderpay(ff).then((res) => {
        if (res.code == 200) {
            this.$message({
          message: '修改成功',
          type: 'success'
        });
           this.dialogVisible = false
           this.getDdList()
        }
      });
    },

    // 业务员修改
    editYwy(data){
        console.log(data)
        this.editYwyForm.salesmanName = data.salesmanName
        this.editYwyForm.salesmanCode = data.salesmanCode
        this.editYwyForm.sheetFee = data.sheetFee
        this.editYwyForm.id = data.id
        this.dialogVisible = true;
    },
    // 业务员确认修改
    editYwyTrue(){
        const ff = {
            salesmanName:this.editYwyForm.salesmanName,
            salesmanCode: this.editYwyForm.salesmanCode,
            sheetFee:this.editYwyForm.sheetFee,
            id: this.editYwyForm.id
        }
        updateSalesman(ff).then((res) => {
        if (res.code == 200) {
            this.$message({
          message: '修改成功',
          type: 'success'
        });
           this.dialogVisible = false
           this.getYwyList()
        }
      });
    },
    // 业务员
    ywyHandleSizeChange(val) {
      this.ywyForm.pageDate.pageSize = val;
      this.getYwyList();

      console.log(`每页 ${val} 条`);
    },
    ywyHandleCurrentChange(val) {
      this.ywyForm.pageDate.pageNum = val;
      this.getYwyList();
      console.log(`当前页: ${val}`);
    },

    // 客户
     khHandleSizeChange(val) {
      this.khForm.pageDate.pageSize = val;
      this.getKhList();

      console.log(`每页 ${val} 条`);
    },
    khHandleCurrentChange(val) {
      this.khForm.pageDate.pageNum = val;
      this.getKhList();
      console.log(`当前页: ${val}`);
    },
    // 承包区
     cbqHandleSizeChange(val) {
      this.cbqForm.pageDate.pageSize = val;
      this.getCbqList();

      console.log(`每页 ${val} 条`);
    },
    cbqHandleCurrentChange(val) {
      this.cbqForm.pageDate.pageNum = val;
      this.getCbqList();
    },

    // 兜底
     ddHandleSizeChange(val) {
      this.ddForm.pageDate.pageSize = val;
      this.getDdList();
    },
    ddHandleCurrentChange(val) {
      this.ddForm.pageDate.pageNum = val;
      this.getDdList();
    },

    // 客户重置
    khClear(){
       for (const key in this.khForm) {
        if (key === "pageDate") {
          // 重置 pageDate 的值为默认值
          this.khForm[key] = { pageNum: 1, pageSize: 10 };
        } else {
          // 清空其他键
          this.khForm[key] = "";
        }
      }
    },

    // 业务员重置
    ywyClear(){
        for (const key in this.ywyForm) {
        if (key === "pageDate") {
          // 重置 pageDate 的值为默认值
          this.ywyForm[key] = { pageNum: 1, pageSize: 10 };
        } else {
          // 清空其他键
          this.ywyForm[key] = "";
        }
      }
    },
     // 承包区重置
    cbqClear(){
        for (const key in this.cbqForm) {
        if (key === "pageDate") {
          // 重置 pageDate 的值为默认值
          this.cbqForm[key] = { pageNum: 1, pageSize: 10 };
        } else {
          // 清空其他键
          this.cbqForm[key] = "";
        }
      }
    },
     // 兜底重置
    ddClear(){
        for (const key in this.ddForm) {
        if (key === "pageDate") {
          // 重置 pageDate 的值为默认值
          this.ddForm[key] = { pageNum: 1, pageSize: 10 };
        } else {
          // 清空其他键
          this.ddForm[key] = "";
        }
      }
    },


    handleClick(tab, event) {
      console.log(tab, event);
      if (tab.index == 0){
        this.getKhList()
      } else if (tab.index == 1){
        this.getYwyList()
      } else if (tab.index == 2){
        this.getCbqList()
      } else if (tab.index == 3){
        this.getDdList()
      }
    },
  },
};
</script>
<style lang="scss" scoped>
.box {
  padding: 0px 20px;
}

.flex {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
}

.flex-bettom {
  display: flex;
  justify-content: space-between;
}

.header {
  padding-bottom: 20px;
  border-bottom: 1px solid #ccc;
}

.el-row {
  margin-bottom: 20px;

  &:last-child {
    margin-bottom: 0;
  }
}

.el-col {
  border-radius: 4px;
}

.bg-purple-dark {
  background: #99a9bf;
}

.bg-purple {
  background: #d3dce6;
}

.bg-purple-light {
  background: #e5e9f2;
}

.grid-content {
  border-radius: 4px;
  min-height: 36px;
}

.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
</style>